<? if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();

$arResult["TAGS_CHAIN"] = array();
if($arResult["REQUEST"]["~TAGS"])
{
	$res = array_unique(explode(",", $arResult["REQUEST"]["~TAGS"]));
	$url = array();
	foreach ($res as $key => $tags)
	{
		$tags = trim($tags);
		if(!empty($tags))
		{
			$url_without = $res;
			unset($url_without[$key]);
			$url[$tags] = $tags;
			$result = array(
				"TAG_NAME" => htmlspecialcharsex($tags),
				"TAG_PATH" => $APPLICATION->GetCurPageParam("tags=".urlencode(implode(",", $url)), array("tags")),
				"TAG_WITHOUT" => $APPLICATION->GetCurPageParam((count($url_without) > 0 ? "tags=".urlencode(implode(",", $url_without)) : ""), array("tags")),
			);
			$arResult["TAGS_CHAIN"][] = $result;
		}
	}
}
//require_once($_SERVER["DOCUMENT_ROOT"]."/include/funcs.php");



if (!$_GET["order"]):
	$_GET["order"]="desc";
endif;

$order = "";
if ($_GET["order"] == "desc"):
	$order = "PROPERTY_MINIMUM_PRICE_VALUE";
else:// asc
	$order = "PROPERTY_MAXIMUM_PRICE_VALUE";
endif;

$arResult["PRODUCT_ITEMS"]=array();
if (CModule::IncludeModule("catalog")):
    foreach ($arResult["SEARCH"] as $item):
        if($item["MODULE_ID"]=="iblock"):
            $rs=CIBlockElement::GetByID($item["ITEM_ID"]);
            while($ar=$rs->GetNext())
            {
                $price = SelectIElement(array(),
                        array("IBLOCK_TYPE"=>"catalog","ID"=>IntVal($ar["ID"])),false,false,
                        array("PROPERTY_MINIMUM_PRICE","PROPERTY_MAXIMUM_PRICE")
                        );
                $arResult["PRODUCT_ITEMS"][] = array("ITEM_ID"=>$ar["ID"],
                                                        "BLOCK_ID"=>$ar["IBLOCK_ID"],
                                                        "date"=>$ar["DATE_CREATE_UNIX"],
                                                        "show"=>$ar["SHOW_COUNTER"],
                                                        "price"=>IntVal($price[0][$order])
                                                        );
                unset($price);
            };
        endif;    
    endforeach;
endif;
/*

*/
?>